Configuring Logging
As detailed in Troubleshooting Logging, Cloudhouse Alchemy Compatibility Packages include a logging component based on log4net to aid troubleshooting. Logging in a Compatibility Package can be changed in the following ways:
Changing the Log Directory
By default, a Compatibility Package's Deployment, Run, and Usage executables log to text files within the current working directory. However, you can configure a Compatibility Package to log to a relative or absolute directory or a directory, based on environment variables.
Process
To change the log directory for a Compatibility Package, complete the following steps:
-
Navigate to the Compatibility Package's folder.
-
Open the relevant config file in a text editor for the type of log file you want to change:
-
Cloudhouse.Container.Deployment.exe.configfor the Deployment log. -
Cloudhouse.Container.Run.exe.configfor the Run log. -
Cloudhouse.Container.Usage.exe.configfor the Usage Log.
-
-
Locate the
<file>element and prepend the directory's path to the name of the file specified for the attribute value. -
Save any files you change.
The next time you deploy or run the Compatibility Package, it will use the newly configured values.
Examples
See the following examples for worked examples.
Note: Text in red indicates changes to the default configuration.
Changing the Fully Qualified File Path
To write to c:\temp\cloudhouse\RunWorkflowLog.txt, change the value to:
<file value="C:\\temp\\Cloudhouse/RunWorkflowLog.txt" />
Changing the Relative Path
To write to a log directory relative to the current directory (for example ..\Logs\Package), change the value to:
<file value="..\\Logs\\Package/RunWorkflowLog.txt" />
Using Environment Variables
To write to the user's local app data use ${APPDATA} or another environment variable:
<file value="${PROGRAMDATA}\Cloudhouse\RunWorkflowLog.txt" />
Configuring Logging to the Windows Event Log
By default, Compatibility Packages log to text files in their current working directory. However, Compatibility Packages can be configured to log to the Windows Event Log instead.
Process
To configure a Compatibility Package to log to the Windows event log, complete the following steps:
-
Open the relevant config file in a text editor for the type of log file you want to change:
-
Cloudhouse.Container.Deployment.exe.configfor the Deployment log. -
Cloudhouse.Container.Run.exe.configfor the Run log. -
Cloudhouse.Container.Usage.exe.configfor the Usage Log.
-
-
Use the sample replacement code below.
-
Change
Cloudhouse AppNameto the desired application name.
Note: Text in red indicates changes to the default configuration.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
<log4net>
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >
<logName value="Application"/>
<applicationName value="Cloudhouse AppName"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %-5level %logger - %message%newline"/>
</layout>
</appender>
<root>
<level value="INFO"/>
<appender-ref ref="ConsoleAppender"/>
<appender-ref ref="EventLogAppender"/>
</root>
</log4net>
</configuration>
Configuring DEBUG Logging
By default, Compatibility Packages log INFO messages when they are deployed or run. However, they can be configured to log INFO, WARNING, ERROR, DEBUG messages if required.
Process
To configure a Compatibility Package to log DEBUG messages, complete the following steps:
-
Open the Source Compatibility Package, not the version that has been deployed.
-
Open the relevant configuration file:
-
Cloudhouse.container.deployment.exe.configfor deployment logging, stored in the same folder the Compatibility Package is being deployed from. -
Cloudhouse.container.run.exe.configfor run logging, stored in the same folder the Compatibility Package is being deployed from.
-
-
Locate the following section inside the relevant config file:
<level value="INFO" />
<appender-ref ref="ConsoleAppender" />
<appender-ref ref="RollingFileAppender" />
</root> -
Change
INFOto the required level, for example forDEBUGthe entry would be:<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
<appender-ref ref="RollingFileAppender" />
</root> -
Save the file.
-
Redeploy/Run the Compatibility Package.